/* 设备管理-设备列表api */

import { ajaxService } from '@/utils/request';
import type * as Ttype from '../type';

const env = import.meta.env;
let baseURL = env.VITE_EQUIPMENT_URL;
let baseURL1 = env.VITE_EQUIPMENT_URL;
let baseURL2 = env.VITE_TAOGESHABI_URL2;

// 获取设备类型数据
export function GetEquipmentList(params: any) {
  return ajaxService({
    url: '/equipment/list/page',
    method: 'get',
    baseURL: baseURL1,
    params,
  });
}
// 删除设备文件
export function DelFile(data: { fileId: number }) {
  return ajaxService({
    url: '/equipment/list/details/file',
    method: 'DELETE',
    baseURL: baseURL1,
    data,
  });
}
// 删除设备图片
export function DelPicture(data: { pictureId: number }) {
  return ajaxService({
    url: '/equipment/list/details/picture',
    method: 'DELETE',
    baseURL: baseURL1,
    data,
  });
}

// 新增设备
export function PostEquipment(data: any) {
  return ajaxService({
    url: '/equipment/list/add',
    method: 'post',
    baseURL: baseURL1,
    data,
  });
}

// 编辑设备
export function PutEquipment(data: any) {
  return ajaxService({
    url: '/equipment/list/add',
    method: 'put',
    baseURL: baseURL1,
    data,
  });
}

// 获取设备详情数据
export function GetEquipmentDetail(params: any) {
  return ajaxService({
    url: '/equipment/list/details',
    method: 'get',
    baseURL: baseURL1,
    params,
  });
}

// 新增设备的时候判断设备编号是否存在
export function IsEquipmentCode(params: any) {
  return ajaxService({
    url: '/equipment/list/check',
    method: 'get',
    baseURL: baseURL1,
    params,
  });
}

// 获取设备列表表头
export function GetEquipmentListHeader(params: any) {
  return ajaxService({
    url: '/equipment/list/header/get',
    method: 'get',
    baseURL: baseURL1,
    params,
  });
}

// 修改设备列表表头
export function PutEquipmentListHeader(data: any) {
  return ajaxService({
    url: '/equipment/list/header/edit',
    method: 'put',
    baseURL: baseURL1,
    data,
  });
}

// 修改启用状态
export function PutEquipmentListState(data: {
  id: number;
  isEnabled: boolean;
}) {
  return ajaxService({
    url: '/equipment/list/page/enable',
    method: 'put',
    baseURL: baseURL1,
    data,
  });
}

// 修改设备状态
export function PutUseStatet(data: { id: number; useStateId: number }) {
  return ajaxService({
    url: '/equipment/list/page/useState',
    method: 'put',
    baseURL: baseURL1,
    data,
  });
}

// 新增编辑保养计划
export function PostEquipmentPlan(data: Ttype.EquipmentMaintenanceType) {
  return ajaxService({
    url: '/equipment/maintain/repair/details/plan',
    method: 'post',
    baseURL: baseURL1,
    data,
  });
}

// 编辑保养计划
export function PutEquipmentPlan(
  data: Ttype.EquipmentMaintenanceType & { id: number }
) {
  return ajaxService({
    url: '/equipment/maintain/repair/details/plan',
    method: 'put',
    baseURL: baseURL1,
    data,
  });
}

// 获取保养计划
export function GetEquipmentPlan(params: Ttype.Tpage) {
  return ajaxService({
    url: '/equipment/maintain/repair/plan/list',
    method: 'get',
    baseURL: baseURL1,
    params,
  });
}

// 删除保养计划
export function DelEquipmentPlan(data: { id: number }) {
  return ajaxService({
    url: '/equipment/maintain/repair/details/plan',
    method: 'DELETE',
    baseURL: baseURL1,
    data,
  });
}
